import Vue from "vue";
import Vuex from "vuex";
import axios from "../src/utils/request"

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    youhui:[
      {
        "id": "007",
        "type": "hot",
        "title": "心动七夕5元优惠劵",
        "useful": "2021.08.09-2021.08.16",
        "price": 5
      },
    ],
    content: [
      {
        addressDetail: "",
        areaCode: "",
        city: "",
        country: "",
        county: "",
        isDefault:"",
        name: "",
        postalCode: "",
        province: "",
        tel: "",
      },
    ],
    dizhi:'',
    isLoading:false,
    num:0,
    sum:[],
    shoplist:[],
    tian:0
  },
  mutations: {
    changeNum(state){
      state.num++
    },
    changeIsLoaging(state,payload){
      state.isLoading = payload.isLoading
    },
    changSum(state,payload){
      state.sum = payload.caidans
      console.log('payload',payload);
    },
    getshoplist(state,payload){
      state.shoplist = payload.shoplists
  }
},
  actions: {
    changeCai(context){
      axios({
        url:"/api/goods/findGoodsByHot"
    })
    .then(res=>{
        context.commit("changSum",{
          caidans:res.data.data
        })
    })
    },
    changeAgeAsync(context){
      axios({
          url:"/api/goods/findLuckMan?typeId=3"
      }).then(res=>{
      context.commit("getshoplist",{
         shoplists:res.data.data
          });
      });            
  }

  },
  modules: {},
});
